<?php

namespace App\Library\Traits\Orm;

use App\Models\PaymentModel;
use App\Models\PaymentRelatedModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

trait AuctionBailOrmTrait
{
    public function paymentRelated(): BelongsTo
    {
        return $this->belongsTo(PaymentRelatedModel::class, 'id', 'object_id')
            ->where('object_type', $this->getTable())->where('status_pay', 1);
    }

    public function payment(): BelongsTo
    {
        return $this->belongsTo(PaymentModel::class, 'id', 'object_id')
            ->where('object_type', $this->getTable())->orderBy('id');
    }
}
